/*
 * Collection.h
 *
 *  Created on: Sep 21, 2011
 *      Author: zwx
 */

#ifndef COLLECTION_H_
#define COLLECTION_H_

#include "../Include/includes.h"
#include "Document.h"
using namespace std;
struct TERM{
	size_t count;
	size_t ID;
};

struct inv_posting{	//the postings info of inverted index
	size_t count;	//the documents count of inverted index
	string postings;//include <docID,term_count,pos1,pos2,...>
};
class Collection {
private:
	static Collection* col;
	static bool instanceFlag;
public:
	list<string> fileList;				//store the path of files
	map<string, size_t> tokenMap;		//token_name, token_count
	map<string, struct TERM> termMap;	//term_name, term_count, term_ID
	set<string> authorSet;				//author_name
	set<string>	categorySet;			//category_name
	set<string> stopwords;
	list<Document*> docList;
	map<size_t, list<size_t>* > invIndex;	//termId, <docId1, docId2....>
	map<size_t, struct inv_posting> posInvIndex; //termID,doc_count,<docID,termCount,pos1,pos2,...>
	map<string, string> autInvMap;
	map<string, string> catInvMap;
	size_t	fileCount;
	size_t	tokenCount;
	size_t	termCount;
	size_t	authorCount;
	size_t	categoryCount;
	size_t 	semWikiCount;
	size_t	fwdIndexCount;

	Collection();
	virtual ~Collection();
	static Collection* 	getInstance();
	void setTokenMap(string name);
	void setTermMap(string name);
	void setInvIndex(size_t termID, size_t docID);
	void setPosInvIndex(size_t termID, string post);
	void setAutInvMap(string, string);
	void setCatInvMap(string, string);
	inline map<string, string>* getAutInvMap() {return &autInvMap;}
	inline map<string, string>* getCatInvMap() {return &catInvMap;}
	inline void setFileList(string name) {fileList.push_back(name);}
	//inline void setLinkSet(string src, string dest) {linkSet.insert(src, dest);};
	inline void setAuthorSet(string name) {authorSet.insert(name); }
	inline void setCategorySet(string name) {categorySet.insert(name);}
	inline void setDocList(Document* doc) { docList.push_back(doc);}
};

#endif /* COLLECTION_H_ */
